#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
  FILE* fp=fopen("myfile","w");
  if(!fp)
  {
    perror("fopen");
  }
  const char* msg="hello jib\n";
  int cnt=5;
  while(cnt--)
  {
    fwrite(msg,strlen(msg),1,fp);
  }
  fclose(fp);
  
  fp=fopen("myfile","r");
  char buf[1024];
  size_t s=fread(buf,1,sizeof(buf)-1,fp);
  if(s>0)
  {
    buf[s]=0;
    printf("%s",buf);
  }
  //if(feof(fp))
  //{
  //  //break;
  //}
  fclose(fp);
  return 0;
}
